package hephantan;

import java.io.*;
import java.net.*;
import java.util.Scanner;

public class Client_Thread {
	public static void main(String[] args) {
		try {
			
			Socket s = new Socket("127.0.0.1",10);
			DataOutputStream os = new DataOutputStream(s.getOutputStream());
			BufferedReader is = new BufferedReader(new InputStreamReader(s.getInputStream()));
			
			while(true){
				System.out.println();
				System.out.println("Nhap vao 1 chuoi - Nhap quit de thoat: ");
				Scanner nhap = new Scanner(System.in);
				String str = nhap.nextLine();
				
				os.writeBytes(str);
				os.write(13);
				os.write(10);
				os.flush();
				
				String st = is.readLine();
				System.out.print(st);
				
				if(st.equals("quit")){
					break;
				}
				
			}
			s.close();
		} catch (IOException e) {
			System.out.println("Loi: khong tao duoc socket ");
		}
		
	}

}
/*Lam bai tap tach chuoi
 *Code nhóm: project trên google.
 *+tạo GUI, kết nối CSDL
 */